<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:s="http://jboss.com/products/seam/taglib"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:a="http://richfaces.org/a4j"
    template="layout/template.xhtml">

<ui:define name="body">

	<h2 class="title"><a href="#">Consultar Auditoria</a></h2><br/>
	
    <h:form id="consultaAuditoriaForm">

			
	        <h:panelGrid columns="1">
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Usuário:</ui:define>
	        		<h:selectOneMenu value="#{consultarAuditoriaController.idUsuario}"
	        			style="width: 200px;">
	        			<f:selectItems value="#{consultarAuditoriaController.listaUsuario}"/>
	        		</h:selectOneMenu>
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Tipo de Operação:</ui:define>
	        		<h:selectOneMenu value="#{consultarAuditoriaController.tipoOperacao}"
	        			style="width: 200px;">
	        			<f:selectItems value="#{consultarAuditoriaController.listaTipos}"/>
	        		</h:selectOneMenu>
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Tabela:</ui:define>
	        		<h:inputText value="#{consultarAuditoriaController.tabela}" 
	        			style="width: 200px;"/>
	        	</s:decorate>
	        	
	        	<s:decorate template="/layout/edit.xhtml">
	        		<ui:define name="label">Período:</ui:define>
	        		<rich:calendar value="#{consultarAuditoriaController.dataInicio}"
	        			datePattern="dd/MM/yyyy"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"/>
	        		à
	        		<rich:calendar value="#{consultarAuditoriaController.dataFim}"
	        			datePattern="dd/MM/yyyy"
	        			enableManualInput="true"
	        			oninputkeydown="Mascara(this,Data)"
	        			oninputkeyup="Mascara(this,Data)"/>
	        	</s:decorate>
	        	
	        </h:panelGrid>
	        
	        <div class="actionButtons">
	            <h:commandButton id="pesq" value="Pesquisar" action="#{consultarAuditoriaController.pesquisar}"
	            	onclick="#{rich:component('carregando')}.show()"/>
	        </div>
	        
	        <center>
	        	<h1>RESULTADO</h1>
	        </center>
	        
	        	
	        	<rich:dataTable var="_result" value="#{consultarAuditoriaController.listaAuditorias}"
	        		rows="10" id="tabelaResultado">
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="Usuário"/></f:facet>
	        			<h:outputText value="#{_result.dscUsuario}"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="Data"/></f:facet>
	        			<h:outputText value="#{_result.dtaOperacao}">
	        				<s:convertDateTime pattern="dd/MM/yyyy HH:mm"/>
	        			</h:outputText>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="Tipo"/></f:facet>
	        			<h:outputText value="#{consultarAuditoriaController.recuperaDescricaoTipoOperacao(_result.tpoOperacao)}"/>
	        		</rich:column>
	        		
	        		<rich:column>
	        			<f:facet name="header"><h:outputText value="Tabela:ID"/></f:facet>
						<h:outputText value="#{_result.dscTabela}:#{_result.idRegistro}"/>
	        		</rich:column>
	        		
	        		<rich:column style="text-align:center;">
	        			<f:facet name="header"><h:outputText value=""/></f:facet>
	        			<a:commandButton value="DETALHE" action="#{consultarAuditoriaController.inicializaPopupDetalhe(_result)}"
	        				image="/img/detalhar.png"
	        				title="Detalhe das alterações"
	        				alt="Detalhe das alterações"
	        				rendered="#{_result.tpoOperacao == 2}"
	        				reRender="formDetalhe" 
	        				oncomplete="#{rich:component('painelDetalheAlteracao')}.show()"/>
	        		</rich:column>
	        		
	        	</rich:dataTable>
	        	<rich:datascroller for="tabelaResultado"/>
	        	
	        	<h:commandButton action="#{excelExporter.export('consultaAuditoriaForm:tabelaResultado')}"
	        		rendered="#{consultarAuditoriaController.listaAuditorias.size() > 0}" 
	        		value="EXPORTAR EXCEL" />

    </h:form>
    
     <rich:modalPanel id="painelDetalheAlteracao" 
	    height="350" width="500">
	    <f:facet name="header">
	        <h:outputText value="Detalhe da alteração" />
	    </f:facet>
	    
	    <f:facet name="controls">
	    	<h:form id="formCancelar">
		    	<a:commandButton value="FECHAR" 
		    		image="/img/close.png" onclick="#{rich:component('painelDetalheAlteracao')}.hide()" />
	    	</h:form>
	    </f:facet>
	    <h:form id="formDetalhe">
	    	<h:outputText value="#{consultarAuditoriaController.detalheAlteracao}" escape="false"/>
	    </h:form>
	</rich:modalPanel>

 </ui:define>
</ui:composition>
